﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using MVCSS = ASPItalia.ModelVirtualCasting.Silverlight.ModelVirtualCastingServices;
using System.Collections.ObjectModel;
using ASPItalia.ModelVirtualCasting.Silverlight.Helpers;

namespace ASPItalia.ModelVirtualCasting.Silverlight.Models
{
  public class DataModelsFakeModel : IDataModelsModel
  {
    public event EventHandler<AllModelsLoadedEventArgs> AllModelsLoadCompleted;
    public event EventHandler<DataLoadingErrorEventArgs> DataLoadingError;

    public DataModelsFakeModel()
    {
      Helper.BaseImageRepositoryUri = "http://localhost:39956/SampleData/ModelSampleDataSource/ModelSampleDataSource_Files/";
    }

    public void GetAllModels()
    {
      ObservableCollection<MVCSS.Model> data = new ObservableCollection<MVCSS.Model>()
      {
          new MVCSS.Model { FirstName = "Anna", LastName = "Magnani",
                    Multimedia =  new ObservableCollection<MVCSS.Multimedia> {
                        new MVCSS.Image { FileName = "FakeModel (1).jpg"},
                        new MVCSS.Image { FileName = "FakeModel (2).jpg"},
                        new MVCSS.Video { FileName = "test.wmv"},
                    },
                },
                new MVCSS.Model { FirstName = "Anna", LastName = "Signorini", 
                                   Multimedia = new ObservableCollection<MVCSS.Multimedia> {
                        new MVCSS.Image { FileName = "FakeModel (3).jpg"},
                        new MVCSS.Image { FileName = "FakeModel (10).jpg"},
                        new MVCSS.Video { FileName = "test.wmv"},
                    },
                }, 
                new MVCSS.Model { FirstName = "Antonella", LastName = "Signorini",
                                    Multimedia = new ObservableCollection<MVCSS.Multimedia> { 
                        new MVCSS.Image { FileName = "FakeModel (11).jpg"},
                        new MVCSS.Image { FileName = "FakeModel (12).jpg"},
                        new MVCSS.Video { FileName = "test.wmv"},
                    },
                },
                new MVCSS.Model { FirstName = "Antonella", LastName = "Young",
                                    Multimedia = new ObservableCollection<MVCSS.Multimedia> {
                        new MVCSS.Image { FileName = "FakeModel (13).jpg"},
                        new MVCSS.Image { FileName = "FakeModel (14).jpg"},
                        new MVCSS.Video { FileName = "test.wmv"},
                    },
                },
                new MVCSS.Model { FirstName = "Francesca", LastName = "Signorini", 
                                   Multimedia = new ObservableCollection<MVCSS.Multimedia> {
                        new MVCSS.Image { FileName = "FakeModel (3).jpg"},
                        new MVCSS.Image { FileName = "FakeModel (10).jpg"},
                        new MVCSS.Video { FileName = "test.wmv"},
                    },
                }, 
                new MVCSS.Model { FirstName = "Annamaria", LastName = "Luciani",
                                    Multimedia = new ObservableCollection<MVCSS.Multimedia> { 
                        new MVCSS.Image { FileName = "FakeModel (11).jpg"},
                        new MVCSS.Image { FileName = "FakeModel (12).jpg"},
                        new MVCSS.Video { FileName = "test.wmv"},
                    },
                },
                new MVCSS.Model { FirstName = "Alba", LastName = "Luciani",
                                    Multimedia = new ObservableCollection<MVCSS.Multimedia> {
                        new MVCSS.Image { FileName = "FakeModel (13).jpg"},
                        new MVCSS.Image { FileName = "FakeModel (14).jpg"},
                        new MVCSS.Video { FileName = "test.wmv"},
                    },
                },
      };
      OnAllModelsLoadCompleted(data);
    }

    public void OnAllModelsLoadCompleted(ObservableCollection<MVCSS.Model> result)
    {
      if (AllModelsLoadCompleted != null)
        AllModelsLoadCompleted(this, new AllModelsLoadedEventArgs(result));
    }

    public void OnDataLoadingError(Exception ex)
    {
      if (DataLoadingError != null)
        DataLoadingError(this, new DataLoadingErrorEventArgs(ex));
    }
  }
}
